package LeetCode;

public class LeetCode_interview0207 {
    public class ListNode {
     int val;
     ListNode next;
     ListNode(int x) {
         val = x;
         next = null;
     }
 }

    public class Solution {
        public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
            ListNode a = headA;
            ListNode b = headB;
            while(a != b){
                a = a !=null? a.next : headB;
                b = b !=null? b.next : headA;
            }

            return a;
        }
    }
}
